<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Parallax Scrolling</title>
  </head>
  <body>
    <div class="one">one</div>
    <div class="two">two</div>
    <div class="three">three</div>
  </body>
  <style>
    /* html {
      overflow: hidden;
      height: 100%;
    } */

    body {
      /* 视差元素的父级需要3D视角 */
      overflow: auto;
      width: 100vw;
      height: 200vh;
      /* background: skyblue; */
      padding-top: 200px;
      perspective: 100px;
      transform-style: preserve-3d;
      /* transform: rotateY(89.9deg); */
      position: relative;
    }
    .one {
      width: 100vw;
      height: 200px;
      background: #409eff;
      transform: translateZ(-50px);
      position: absolute;
      top: 50%;
      left: 20px;
      /* margin-bottom: 50px; */
    }
    .two {
      width: 100vw;
      height: 200px;
      background: #67c23a;
      transform: translateZ(0px);
      position: absolute;
      top: 50%;
      left: 40px;
      /* margin-bottom: 150px; */
    }
    .three {
      width: 100vw;
      height: 200px;
      background: #e6a23c;
      transform: translateZ(50px);
      position: absolute;
      top: 50%;
      left: 60px;
      /* margin-bottom: 150px; */
    }
  </style>
</html>
